<html>
<!-- =====================================================================

  File:      Generated file for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
<head>
  <link rel=stylesheet href=style.css>
</head>
<body>
<div class=SourcePanel style="font-size:12">
<pre style="background-color:white">
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Configuration</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span>.<span style="color: #2040a0">SqlClient</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Threading</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Globalization</span><span style="color: #4444FF">;</span>

<span style="color: #008000">/*=====================================================================

  File:      OrdersDB.cs for Adventure Works Cycles Storefront Sample
  Summary:   Middle tier component for manipulating sales orders.
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */</span>

<span style="color: #0000FF"><strong>namespace</strong></span> <span style="color: #2040a0">Microsoft</span>.<span style="color: #2040a0">Samples</span>.<span style="color: #2040a0">SqlServer</span>
<span style="color: #4444FF"><strong>{</strong></span>
	<span style="color: #008000">//*******************************************************</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">// OrderDetails Class</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">// A simple data class that encapsulates details about</span>
	<span style="color: #008000">// a particular order inside the AdventureWorks</span>
	<span style="color: #008000">// database.</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">// Note that it is bad style to expose public fields.  So </span>
	<span style="color: #008000">// instead we maintain private fields with corresponding</span>
	<span style="color: #008000">// public properties.  This helps avoid binary </span>
	<span style="color: #008000">// incompatabilities if the public fields were to have to</span>
	<span style="color: #008000">// be changed to properties later.</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">//*******************************************************</span>
	<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">OrderDetails</span>
	<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">DateTime</span> <span style="color: #2040a0">orderDate</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">DateTime</span> <span style="color: #2040a0">shipDate</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">orderTotal</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">DataSet</span> <span style="color: #2040a0">orderItems</span><span style="color: #4444FF">;</span>

		<span style="color: #008000">// The fields above are exposed publically as properties</span>
		<span style="color: #008000">// There is nothing fancy going on here, it is just better </span>
		<span style="color: #008000">// practice to not expose public fields.</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">DateTime</span> <span style="color: #2040a0">OrderDate</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">orderDate</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">orderDate</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">DateTime</span> <span style="color: #2040a0">ShipDate</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">shipDate</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">shipDate</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">OrderTotal</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">orderTotal</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">orderTotal</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">DataSet</span> <span style="color: #2040a0">OrderItems</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">orderItems</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">orderItems</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
	<span style="color: #4444FF"><strong>}</strong></span>

	<span style="color: #008000">//*******************************************************</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">// OrderHistoryDB Class</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">// Business/Data Logic Class that encapsulates all data</span>
	<span style="color: #008000">// logic necessary to query past orders within the</span>
	<span style="color: #008000">// AdventureWorks database.</span>
	<span style="color: #008000">//</span>
	<span style="color: #008000">//*******************************************************</span>
	<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">OrdersDB</span>
	<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// CustomerDB.GetCustomerOrders() Method &lt;a name=&quot;GetCustomerOrders&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetCustomerOrders method returns a DataReader containing </span>
		<span style="color: #008000">// a list of all past orders placed by a specified customer.</span>
		<span style="color: #008000">// The SQLDataReaderResult struct also returns the SQL connection,</span>
		<span style="color: #008000">// which must be explicitly closed after the data from the DataReader</span>
		<span style="color: #008000">// is bound into the controls.</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_OrdersList.htm&quot; style=&quot;color:green&quot;&gt;usp_OrdersList Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">SqlDataReader</span> <span style="color: #2040a0">GetCustomerOrders</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_OrdersList&quot;</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Add Parameters to SPROC</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerid</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>,
																<span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>,
																<span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterCustomerid</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">Int32</span>.<span style="color: #2040a0">Parse</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span>,
													<span style="color: #2040a0">CultureInfo</span>.
													<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerid</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCulture</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Culture&quot;</span>,
															 <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>,
															 <span style="color: #FF0000">10</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterCulture</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">CurrentUICulture</span>.<span style="color: #2040a0">Name</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Return the datareader result\</span>
			<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteReader</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CommandBehavior</span>.<span style="color: #2040a0">CloseConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// OrdersDB.GetSalesOrderAddresses() Method &lt;a name=&quot;GetCustomerDefaultAddresses&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetSalesOrderAddresses method returns </span>
		<span style="color: #008000">// a DataSet containing two tables -- the billing and shipping address tables for the </span>
		<span style="color: #008000">// specified sales order.  Each table has one row.</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_OrdersAddresses&quot; style=&quot;color:green&quot;&gt;usp_OrdersAddresses Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddresses</span> <span style="color: #2040a0">GetSalesOrderAddresses</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">salesOrderID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_OrdersAddresses&quot;</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">customerIDParameter</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderID&quot;</span>,
																<span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerIDParameter</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">customerIDParameter</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">salesOrderID</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">DataSet</span> <span style="color: #2040a0">ds</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">DataSet</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;Default Addresses&quot;</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Locale</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">SqlDataAdapter</span> <span style="color: #2040a0">sda</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlDataAdapter</span><span style="color: #4444FF">(</span><span style="color: #2040a0">myCommand</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">sda</span>.<span style="color: #2040a0">Fill</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">CustomerAddresses</span> <span style="color: #2040a0">result</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerAddresses</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>new</strong></span>
				<span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span>, <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">&gt;</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">result</span>.<span style="color: #2040a0">BillingAddress</span>.<span style="color: #2040a0">FillAddress</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span><span style="color: #4444FF">[</span><span style="color: #FF0000">0</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">&gt;</span> <span style="color: #FF0000">1</span><span style="color: #4444FF">)</span>
					<span style="color: #2040a0">result</span>.<span style="color: #2040a0">ShippingAddress</span>.<span style="color: #2040a0">FillAddress</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span><span style="color: #4444FF">[</span><span style="color: #FF0000">1</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>

			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">result</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>	

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// OrdersDB.GetOrderDetails() Method &lt;a name=&quot;GetOrderDetails&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetOrderDetails method returns an OrderDetails</span>
		<span style="color: #008000">// instance containing information about the specified</span>
		<span style="color: #008000">// order.</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_OrdersDetail.htm&quot; style=&quot;color:green&quot;&gt;usp_OrdersDetail Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">// </span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">OrderDetails</span> <span style="color: #2040a0">GetOrderDetails</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">orderID</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlDataAdapter</span> <span style="color: #2040a0">myAdapter</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlDataAdapter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_OrdersDetail&quot;</span>,
														  <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myAdapter</span>.<span style="color: #2040a0">SelectCommand</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Add Parameters to SPROC</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderID&quot;</span>,
															 <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">orderID</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCurrencyCode</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Culture&quot;</span>,
																  <span style="color: #2040a0">SqlDbType</span>.
																  <span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">10</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterCurrencyCode</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">CurrentUICulture</span>.<span style="color: #2040a0">Name</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCurrencyCode</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderDate</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderDate&quot;</span>,
															   <span style="color: #2040a0">SqlDbType</span>.
															   <span style="color: #2040a0">DateTime</span>, <span style="color: #FF0000">8</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderDate</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderDate</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterShipDate</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@ShipDate&quot;</span>,
															  <span style="color: #2040a0">SqlDbType</span>.
															  <span style="color: #2040a0">DateTime</span>, <span style="color: #FF0000">8</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterShipDate</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterShipDate</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderTotal</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderTotal&quot;</span>,
																<span style="color: #2040a0">SqlDbType</span>.
																<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">20</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderTotal</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderTotal</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">DataSet</span> <span style="color: #2040a0">myDataSet</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">DataSet</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;OrderDetails&quot;</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myDataSet</span>.<span style="color: #2040a0">Locale</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">myAdapter</span>.<span style="color: #2040a0">Fill</span><span style="color: #4444FF">(</span><span style="color: #2040a0">myDataSet</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// ship date is null if order doesn't exist, or belongs to a different user</span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">parameterShipDate</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">DBNull</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #008000">// Create and Populate OrderDetails Struct using</span>
				<span style="color: #008000">// Output Params from the SPROC, as well as the</span>
				<span style="color: #008000">// data reader.</span>
				<span style="color: #2040a0">OrderDetails</span> <span style="color: #2040a0">myOrderDetails</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">OrderDetails</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderDate</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">DateTime</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterOrderDate</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">ShipDate</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">DateTime</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterShipDate</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderTotal</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterOrderTotal</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderItems</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myDataSet</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Return the information about the order as an instance of the OrderDetails class.</span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">myOrderDetails</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #0000FF"><strong>else</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">null</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// OrdersDB.GetShippingMethods() Method &lt;a name=&quot;GetShippingMethods&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetShippingMethods method returns </span>
		<span style="color: #008000">// a forward-only, read-only DataReader.  This returns a list of all</span>
		<span style="color: #008000">// shipping methods. </span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_OrdersShippingMethods&quot; style=&quot;color:green&quot;&gt;usp_OrdersShippingMethods Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">SqlDataReader</span> <span style="color: #2040a0">GetShippingMethods</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_OrdersShippingMethods&quot;</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Return the datareader result</span>
			<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteReader</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CommandBehavior</span>.<span style="color: #2040a0">CloseConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// OrdersDB.CalculateShippingDate() Method &lt;a name=&quot;CalculateShippingDate&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The CalculateShippingDate method would be where you would</span>
		<span style="color: #008000">// place all of the code necessary to calculate the shipping</span>
		<span style="color: #008000">// ETA.  For now, we are just making up a random date.</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">DateTime</span> <span style="color: #2040a0">CalculateShippingDate</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">cartID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">Random</span> <span style="color: #2040a0">x</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">Random</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>double</strong></span> <span style="color: #2040a0">myrandom</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>double</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">x</span>.<span style="color: #2040a0">Next</span><span style="color: #4444FF">(</span><span style="color: #FF0000">0</span>, <span style="color: #FF0000">3</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">DateTime</span>.<span style="color: #2040a0">Now</span>.<span style="color: #2040a0">AddDays</span><span style="color: #4444FF">(</span><span style="color: #2040a0">myrandom</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// OrdersDB.PlaceOrder() Method &lt;a name=&quot;PlaceOrder&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The PlaceOrder method places an order within the</span>
		<span style="color: #008000">// AdventureWorks Database and then clears out the current</span>
		<span style="color: #008000">// items within the shopping cart.</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_OrdersAdd.htm&quot; style=&quot;color:green&quot;&gt;usp_OrdersAdd Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">PlaceOrder</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">cartID</span>,
							  <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">shippingMethod</span>, <span style="color: #2040a0">Constants</span>.<span style="color: #2040a0">Status</span> <span style="color: #2040a0">orderStatus</span>,
							  <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">billToAddressID</span>, <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">shipToAddressID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span>
					   <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_OrdersAdd&quot;</span>, <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Add Parameters to SPROC</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>,
																<span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>,
																<span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">Int32</span>.<span style="color: #2040a0">Parse</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span>,
													<span style="color: #2040a0">CultureInfo</span>.
													<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCartID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CartID&quot;</span>,
															<span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>,
															<span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterCartID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">cartID</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCartID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterShipDate</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@ShipDate&quot;</span>,
															  <span style="color: #2040a0">SqlDbType</span>.
															  <span style="color: #2040a0">DateTime</span>, <span style="color: #FF0000">8</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterShipDate</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CalculateShippingDate</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">cartID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterShipDate</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderDate</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderDate&quot;</span>,
															   <span style="color: #2040a0">SqlDbType</span>.
															   <span style="color: #2040a0">DateTime</span>, <span style="color: #FF0000">8</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderDate</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">DateTime</span>.<span style="color: #2040a0">Now</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderDate</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterShippingMethod</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@ShippingMethod&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterShippingMethod</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">shippingMethod</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterShippingMethod</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderStatus</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Status&quot;</span>,
																 <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>,
																 <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderStatus</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">orderStatus</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderStatus</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterBillToAddressID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@BillToAddressID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterBillToAddressID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">billToAddressID</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterBillToAddressID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterShipToAddressID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@ShipToAddressID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterShipToAddressID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">shipToAddressID</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterShipToAddressID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterOrderID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@OrderID&quot;</span>,
															 <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterOrderID</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterOrderID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Open the connection and execute the Command</span>
			<span style="color: #2040a0">try</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">finally</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">State</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">ConnectionState</span>.<span style="color: #2040a0">Closed</span><span style="color: #4444FF">)</span>
					<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Close</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>

			<span style="color: #008000">// Return the OrderID</span>
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterOrderID</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>
	<span style="color: #4444FF"><strong>}</strong></span>
<span style="color: #4444FF"><strong>}</strong></span>


</pre>
